package com.carleasoft.mps.cms.business.repairs.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carleasoft.mps.cms.business.repairs.bean.entity.RepairsGroup;
import com.carleasoft.mps.cms.business.repairs.bean.po.RepairsGroupAddOrEditPo;
import com.carleasoft.mps.cms.business.repairs.bean.po.RepairsGroupPageQueryPo;
import com.carleasoft.mps.cms.business.repairs.bean.po.SetDealPersonPo;
import com.carleasoft.mps.cms.business.repairs.service.RepairsGroupService;
import com.carleasoft.mps.core.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 维修组接口
 * @Author: fan
 */
@RestController
@RequestMapping("/repairs")
public class RepairsGroupController {
    @Autowired
    private RepairsGroupService repairsGroupService;

    /**
     * 维修组成员-添加
     */
    @PostMapping("/add")
    public R add(@RequestBody RepairsGroupAddOrEditPo repairsGroupAddOrEditPo){
        return R.ok(repairsGroupService.add(repairsGroupAddOrEditPo));
    }
    /**
     * 维修组成员-编辑
     */
    @PostMapping("/edit")
    public R edit(@RequestBody RepairsGroupAddOrEditPo repairsGroupAddOrEditPo){
        return R.ok(repairsGroupService.edit(repairsGroupAddOrEditPo));
    }
    /**
     * 维修组成员-删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody RepairsGroup repairsGroup){
        return R.ok(repairsGroupService.delete(repairsGroup));
    }
    /**
     * 维修组成员-分页
     */
    @PostMapping("/pageQuery")
    public R<Page<RepairsGroup>> pageQuery(@RequestBody RepairsGroupPageQueryPo repairsGroupPageQueryPo){
        return R.ok(repairsGroupService.pageQuery(repairsGroupPageQueryPo));
    }
    /**
     * 维修组成员-列表
     */
    @PostMapping("/list")
    public R<List<RepairsGroup>> list(@RequestBody RepairsGroup repairsGroup){
//        QueryWrapper<RepairsGroup> queryWrapper = new QueryWrapper<>();
//        queryWrapper.orderByDesc("UPDATE_TIME");
//        if (repairsGroup.getPersonType()!=null && repairsGroup.getPersonType()!=""){
//            queryWrapper.like("PERSON_TYPE",repairsGroup.getPersonType());
//        }
        return R.ok(repairsGroupService.selList(repairsGroup));
    }
    /**
     * 维修组成员-详情
     */
    @PostMapping("/detail")
    public R<RepairsGroup> detail(@RequestBody RepairsGroup repairsGroup){
        return R.ok(repairsGroupService.detail(repairsGroup));
    }
    /**
     * 设置各专业综合处理人
     */
    @PostMapping("/setDealPerson")
    public R<Boolean> setDealPerson(@RequestBody SetDealPersonPo setDealPersonPo){
        return R.ok(repairsGroupService.setDealPerson(setDealPersonPo));
    }
    /**
     * 查询各专业综合处理人
     */
    @PostMapping("/selDealPerson")
    public R<SetDealPersonPo> selDealPerson(){
        return R.ok(repairsGroupService.selDealPerson());
    }

}
